<?php
include '../configs/connect.php';
include '../lib/BLL/DonViBLL.php';
include '../lib/BLL/DmNganhBLL.php';
include '../lib/BLL/DmMonHocBLL.php';
include '../lib/BLL/CanBoBLL.php';
include '../lib/BLL/VaitroHoiDongBLL.php';
?>
<tbody>
			<tr>
            
				<th class="cangiua">STT</th>
				<th class="cangiua">Mã Cán Bộ<th>
				<th style="text-align:left">Tên Cán bộ</th>
				<th style="text-align:left">Giới tính</th>
				<th class="cangiua">Ngày sinh</th>
				<th class="cangiua">Chức vụ</th>
			</tr>
<?php
	$cb=new CanBoBLL();
	$ds_cb=$cb->getListCanBo();
	$i=1;
	$listcb=array();
	$vaitro=new VaiTroHoiDongBLL();
	$ds_vaitro=$vaitro->getListVaitroHoiDong();
	if(isset($_GET['mahoidong']))
	{
		$ma_hoidong_cb=$_GET['mahoidong'];
		mysql_query("DELETE FROM tbl_hoidong_canbo WHERE ma_hoidong_cb='$ma_hoidong_cb'");
	}
	foreach($ds_cb as $value)
	{
		if($value->gethoten_cb() !='Admin')
		{
			$macb=$value->getma_cb()
?>
			
			<tr>
			<td class="cangiua"><?php echo $i ?></td>
			<td class="cangiua"><?php echo $value->getma_cb() ?></td>
			<td  colspan="2" style="padding-left:40px"><?php echo $value->gethoten_cb() ?></td>
            <td class=""><?php echo $value->getgioitinh_cb() ?></td>
            <td class="cangiua"><?php echo $value->getngaysinh_cb() ?></td>
			<td class="cangiua">
			<?php
				$sql="select *from tbl_canbo inner join tbl_hoidong_canbo on tbl_canbo.ma_cb=tbl_hoidong_canbo.ma_cb
							inner join tbl_vaitro_hoidong on ma_vaitro_hoidong = ma_vaitro where tbl_canbo.ma_cb='".$value->getma_cb()."'";
				$query=mysql_query($sql);		
				if(mysql_num_rows($query)==0)
				{		
			?>
				<select name="<?php echo $value->getma_cb() ?>">
                	<option value="">-Chọn vai trò-</option>
               		 <?php
					foreach($ds_vaitro as $value)
					{
					?>
						<option value="<?php echo $value->getma_vaitro() ?>"><?php echo $value->getten_vaitro() ?></option>
                	<?php
					}
					?>
				</select>
            <?php
				}
				else{
					while($row=mysql_fetch_array($query))
					{
			?>
    					<input style="width:108px;height:23px;margin:0px 0px 0px 43px;border:1px solid #CCC;border-radius:5px;text-align:center;float:left;" type="text" value="<?php echo $row['ten_vaitro'] ?>" name="<?php $row['macb'] ?>">
						<img style="margin:0px 0px 0px 10px;float:left" src="../php/images/del.png" onclick="xoadanhsachhoidong(<?php echo $row['ma_hoidong_cb'] ?>);"/>
			<?php		
					}
				}
			?>
             
			</td>	
			</tr>
			<tr>
                <td colspan="10">
                    <label id="chitiet0"></label>
                    <input name="nganhluu0" id="nganhluu0" type="hidden">
                    <input name="lopluu0" id="lopluu0" type="hidden">
                    
                </td>
            </tr>
	<?php
			$i++;
		}
		}
	?>	
			<tr>
				<td colspan="3"><input class="button" type="submit" name="Luu" value="Lưu" ></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
			</tr>		
</tbody>
